package com.dhj.yygh.controller;

import com.dhj.yygh.common.result.MyResult;
import com.dhj.yygh.model.hosp.Schedule;
import com.dhj.yygh.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "医院排班接口")
@RestController
@RequestMapping("/admin/hospital/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation("根据医院编号和科室编号查询排班规则,分页展示")
    @GetMapping("/getScheduleRuleByHoscodeAndDepcode/{page}/{pageCount}/{hoscode}/{depcode}")
    public MyResult<Map<String, Object>> getScheduleRule(
            @PathVariable("page") Integer page,
            @PathVariable("pageCount") Integer pageCount,
            @PathVariable("hoscode") String hoscode,
            @PathVariable("depcode") String depcode) {

        Map<String, Object> ruleMap = scheduleService.getScheduleRule(page, pageCount, hoscode, depcode);

        return MyResult.ok(ruleMap);
    }

    @ApiOperation("根据医院编号和科室编号以及工作日期查询排班详情")
    @GetMapping("/getScheduleDetails/{hoscode}/{depcode}/{workDate}")
    public MyResult<List<Schedule>> getScheduleDetails(
            @PathVariable("hoscode") String hoscode,
            @PathVariable("depcode") String depcode,
            @PathVariable("workDate") String workDate){

        List<Schedule> scheduleList = scheduleService.getScheduleDetails(hoscode,depcode,workDate);
        return MyResult.ok(scheduleList);
    }
}
